# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
-bin_SCRIPTS += src/ostbuild/ostbuild-compile-one \
+bin_SCRIPTS += \
+ src/ostbuild/ostbuild-autodiscover-meta \
src/ostbuild/ostbuild-compile-one-impl \
- src/ostbuild/ostbuild-chroot-compile-one \
src/ostbuild/ostbuild-chroot-compile-one-impl \
src/ostbuild/ostbuild-nice-and-log-output \
$(NULL)
--- /dev/null
+#!/usr/bin/python
+#
+# Copyright (C) 2011 Colin Walters <walters@verbum.org>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+import os,sys,re,subprocess,tempfile,shutil
+import argparse
+
+parser = argparse.ArgumentParser(description="Discover source metadata from current directory")
+parser.add_argument('--meta')
+
+args = parser.parse_args()
+
+AUTODISCOVERED_KEYS = {}
+KEYS = {}
+
+def _register_discover_func(key, func):
+ if key not in AUTODISCOVERED_KEYS:
+ AUTODISCOVERED_KEYS[key] = []
+ AUTODISCOVERED_KEYS[key].append(func)
+
+def _discover_name_from_cwd():
+ return os.path.basename(os.getcwd())
+_register_discover_func('NAME', _discover_name_from_cwd)
+
+def _discover_version_from_git():
+ if os.path.isdir('.git'):
+ try:
+ version = subprocess.check_output(['git', 'describe'])
+ except subprocess.CalledProcessError, e:
+ version = subprocess.check_output(['git', 'rev-parse', 'HEAD'])
+ return version.strip()
+ return None
+_register_discover_func('VERSION', _discover_version_from_git)
+
+if args.meta:
+ f = open(args.meta)
+ for line in f.readlines():
+ (k,v) = line.split('=', 1)
+ KEYS[k.strip()] = v.strip()
+ f.close()
+
+for (key,hooks) in AUTODISCOVERED_KEYS.iteritems():
+ if key in KEYS:
+ continue
+ for func in hooks:
+ value = func()
+
+ if value is None:
+ continue
+
+ KEYS[key] = value
+ break
+
+for (key,value) in KEYS.iteritems():
+ print "%s=%s" % (key, value)
+
+++ /dev/null
-#!/bin/sh
-#
-# Copyright (C) 2011 Colin Walters <walters@verbum.org>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-#
-# Author: Colin Walters <walters@verbum.org>
-
-
-bn=$(basename $(pwd))
-ostbuild-nice-and-log-output "compile-${bn}.log" ostbuild-chroot-compile-one-impl "$@"
import os,sys,re,subprocess,tempfile,shutil
import argparse
+sys.path
+
def get_build_env():
return {'HOME' : '/',
'HOSTNAME' : 'ostbuild',
parser.add_argument('--repo')
parser.add_argument('--resultdir')
parser.add_argument('--branch')
+parser.add_argument('--meta')
parser.add_argument('--debug-shell', type=bool)
args = parser.parse_args()
+++ /dev/null
-#!/bin/sh
-#
-# Copyright (C) 2011 Colin Walters <walters@verbum.org>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-#
-# Author: Colin Walters <walters@verbum.org>
-
-bn=$(basename $(pwd))
-ostbuild-nice-and-log-output "compile-${bn}.log" ostbuild-compile-one-impl "$@"
# http://people.gnome.org/~walters/docs/build-api.txt
import os,sys,subprocess,tempfile,re
+from StringIO import StringIO
from multiprocessing import cpu_count
import select,time
top_srcdir=os.getcwd()
ostbuild_resultdir=top_srcdir
+ostbuild_meta=None
for arg in sys.argv[1:]:
if arg.startswith('OSTBUILD_RESULTDIR='):
ostbuild_resultdir=arg[len('OSTBUILD_RESULTDIR='):]
+ elif arg.startswith('OSTBUILD_META='):
+ ostbuild_meta=arg[len('OSTBUILD_META='):]
elif arg.startswith('--'):
configargs.append(arg)
else:
makeargs.append(arg)
+metadata = {}
+
+if ostbuild_meta is None:
+ output = subprocess.check_output(['ostbuild-autodiscover-meta'])
+ ostbuild_meta_f = StringIO(output)
+else:
+ ostbuild_meta_f = open(ostbuild_meta)
+
+for line in ostbuild_meta_f:
+ (k,v) = line.split('=', 1)
+ metadata[k.strip()] = v.strip()
+
+for k in ['NAME', 'VERSION']:
+ if k not in metadata:
+ sys.stderr.write('Missing required key "%s" in metadata' % (k, ))
+ sys.exit(1)
+
def log(msg):
fullmsg = '%s: %s\n' % (sys.argv[0], msg)
sys.stdout.write(fullmsg)
log("created: %s" % (os.path.abspath (result_path), ))
def phase_make_artifacts(builddir=None):
- basename=os.path.basename(os.getcwd())
-
- try:
- version = subprocess.check_output(['git', 'describe'])
- except subprocess.CalledProcessError, e:
- version = subprocess.check_output(['git', 'rev-parse', 'HEAD'])
- version = version.strip()
-
- version = version.replace(',', '_')
+ name = metadata['NAME']
+ version = metadata['VERSION']
+ assert ',' not in version
- artifact_prefix='artifact-%s-%s,%s' % (build_target, basename, version)
+ artifact_prefix='artifact-%s-%s,%s' % (build_target, name, version)
- tempdir = tempfile.mkdtemp(prefix='ostree-build-%s-' % (basename,))
+ tempdir = tempfile.mkdtemp(prefix='ostree-build-%s-' % (name,))
tempfiles.append(tempdir)
args = ['make', 'install', 'DESTDIR=' + tempdir]
run_sync(args, cwd=builddir)